package com.whf.android.jar.util.log;

import com.blankj.utilcode.util.GsonUtils;
import com.orhanobut.logger.Logger;


/**
 * @author wang.hai.fang
 * @link (rewrite)android.util.Log
 * @code class
 * @since (Original position) android.util.Log
 */
public final class LatteLogger {

    private final static String TAG = "TAG";

    private static final int VERBOSE = 1;
    private static final int DEBUG = 2;
    private static final int INFO = 3;
    private static final int WARN = 4;
    private static final int ERROR = 5;
    private static final int NOTHING = 6;

    /**
     * 控制log等级
     */
    private static int LEVEL = VERBOSE;


    public static void v(String message) {
        if (LEVEL <= VERBOSE) {
            Logger.t(TAG).v(message);
        }
    }

    public static void v(String tag, String message) {
        if (LEVEL <= VERBOSE) {
            Logger.t(tag).v(message);
        }
    }

    public static void d(String tag, Object message) {
        if (LEVEL <= DEBUG) {
            Logger.t(tag).d(message);
        }
    }

    public static void d(Object message) {
        if (LEVEL <= DEBUG) {
            Logger.d(message);
        }
    }

    public static void i(String message) {
        if (LEVEL <= INFO) {
            Logger.t(TAG).i(message);
        }
    }

    public static void i(String tag, String message) {
        if (LEVEL <= INFO) {
            Logger.t(tag).i(message);
        }
    }

    public static void i(Object message) {
        if (LEVEL <= WARN) {
            Logger.t(TAG).i(GsonUtils.toJson(message));
        }
    }

    public static void w(String tag, String message) {
        if (LEVEL <= WARN) {
            Logger.t(tag).w(message);
        }
    }

    public static void json(String message) {
        if (LEVEL <= WARN) {
            Logger.t(TAG).json(message);
        }
    }

    public static void json(String tag, String message) {
        if (LEVEL <= WARN) {
            Logger.t(tag).json(message);
        }
    }

    public static void e(String message) {
        if (LEVEL <= ERROR) {
            Logger.t(TAG).e(message);
        }
    }

    public static void e(String tag, String message) {
        if (LEVEL <= ERROR) {
            Logger.t(tag).e(message);
        }
    }


    /**
     * log
     *
     * @param obj:Print string
     */
    public static void d(String obj) {
        d(TAG, obj);
    }

    /**
     * log
     *
     * @param obj:Print string
     */
    public static void w(String obj) {
        w(TAG, obj);
    }


    /**
     * log
     *
     * @param s:is      ok
     * @param obj:Print string
     */
    public static void is(boolean s, String obj) {
        if (s) {
            i(obj + "-OK-");
        } else {
            e(obj + "-NO-");
        }
    }
}
